ENT.Type = "anim"

ENT.IsHoverGear = true

ENT.MaxHealth = 250

function ENT:SetVehicleOwner(owner)
	self:SetDTEntity(0, owner)
end

function ENT:GetVehicleOwner()
	return self:GetDTEntity(0)
end

function ENT:GetVehicleHealth()
	return self:GetDTFloat(0)
end

function ENT:SetVehicleHealth(health)
	self:SetDTFloat(0, math.Clamp(health, 0, self.MaxHealth))
end

function ENT:GetStunTime()
	return self:GetDTFloat(1)
end

function ENT:SetStunTime(time)
	self:SetDTFloat(1, time)
end

function ENT:SetPrimaryPowerup(ent)
	self:SetDTEntity(1, ent)
end

function ENT:GetPrimaryPowerup()
	return self:GetDTEntity(1)
end

function ENT:SetSecondaryPowerup(ent)
	self:SetDTEntity(2, ent)
end

function ENT:GetSecondaryPowerup()
	return self:GetDTEntity(2)
end

function ENT:CallOnPrimary(funcname, ...)
	local primary = self:GetPrimaryPowerup()
	if primary:IsValid() and primary[funcname] then
		primary[funcname](primary, ...)
	end
end

function ENT:CallOnSecondary(funcname, ...)
	local primary = self:GetPrimaryPowerup()
	if primary:IsValid() and primary[funcname] then
		primary[funcname](primary, self, ...)
	end
end

function ENT:CallOnAll(funcname, ...)
	self:CallOnPrimary(funcname, ...)
	self:CallOnSecondary(funcname, ...)
end

function ENT:KeyPress(pl, key)
	self:CallOnAll("KeyPress", pl, key)
end

function ENT:KeyRelease(pl, key)
	self:CallOnAll("KeyRelease", pl, key)
end

function ENT:GetPilotEyePos()
	return self:GetPos() + (self:GetUp() * 20 + self:GetRight() * -10 + self:GetForward() * 4) * SCALE
end

function ENT:GetDashboardPos()
	return self:GetPos() + (self:GetUp() * 12 + self:GetRight() * -8 + self:GetForward() * 23) * SCALE
end

function ENT:GetBackBumperPos()
	return self:GetPos() + SCALE * -75 * self:GetForward()
end

function ENT:GetBackBumperAng()
	local ang = self:GetAngles()
	ang:RotateAroundAxis(ang:Up(), -90)
	ang:RotateAroundAxis(ang:Forward(), 90)
	return ang
end

function ENT:GetDashboardAng()
	local ang = self:GetAngles()
	ang:RotateAroundAxis(ang:Up(), -90)
	ang:RotateAroundAxis(ang:Forward(), 80)
	return ang
end

util.PrecacheSound("ambient/machines/thumper_shutdown1.wav")
util.PrecacheSound("ambient/machines/thumper_startup1.wav")
